#include <iostream>
#include <algorithm>
using namespace std;

signed main()
{
    int n,a[100005],cnt = 0;
    cin>>n;
    for(int i=0;i<n;i++)    cin>>a[i];
    sort(a,a+n);
    for(int i=n-1;i>=0;i--){
        cnt++;
        if(a[i]<=cnt){
            cout<<cnt-1;
            return 0;
        }
    }
    cout<<n;
    return 0;
}
